﻿using Basic.WxRemoteModel.WxBind.Model;
using Basic.WxRemoteModel.WxMsg.Model;
using Basic.WxService.ConstDic;
using Basic.WxService.Interface;
using WeDonekRpc.Client.Attr;

namespace Basic.WxService.PlatformMsg
{
    [IocName(WxPlatformEventDic.Authorized)]
    internal class AuthorizedMsgEvent : IWxPlatformMsgEvent
    {
        private readonly IWxBindService _WxMerBind;

        public AuthorizedMsgEvent (IWxBindService wxMerBind)
        {
            this._WxMerBind = wxMerBind;
        }

        public void ExecMsg (WxPlatformMsg msg)
        {
            this._WxMerBind.Begin(new WxMerBind
            {
                PlatformAppId = msg.PlatformAppId,
                PreAuthCode = msg.EventBody["PreAuthCode"],
                WxAppId = msg.EventBody["AuthorizerAppid"],
                WxCode = msg.EventBody["AuthorizationCode"]
            });
        }
    }
}
